<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/15
 * Time: 14:45
 */
$client = new swoole_client(SWOOLE_SOCK_UDP);
if(!$client->connect("127.0.0.1", 9502)){
    echo "connect failed!";
    exit;
}
//php cli 常量
fwrite(STDOUT, "请输入消息：");
$msg = trim(fgets(STDIN));
//给udp server 发送数据
$client->sendto("127.0.0.1", 9502, $msg);

//接收udp server返回的数据
$result = $client->recv();
echo $result . PHP_EOL;